const path = require('path')

module.exports = {
  css: {
    loaderOptions: {
      scss: {
        // 全局的scss 配置
        // eslint-disable-next-line quotes
        prependData: `@import "~@/assets/scss/index.scss";`
      },
      postcss: {
        plugins: [
          require('postcss-px2rem')({
            remUnit: 100
          })
        ]
      }
    }
  },
  devServer: {
    proxy: {
      "/api": {
        target: "http://localhost:7001",
        changeOrigin: true
        // pathRewrite: {
        //   "^/api": ""
        // }
      }
    }
  },
  chainWebpack: (config) => {
    config.module.rules.delete('svg');
    config.module
      .rule('svg-sprite-loader')
      .test(/\.svg$/)
      .include
        .add(path.resolve(__dirname, './src/assets/icon'))
        .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      });
  }
}
